/**
 * @author        Nicolas Bottarini <nicolasbottarini@gmail.com>, 404 <http://www.proyecto404.com>
 * @version       $Rev: 3 $
 * @lastrevision  $Date: 2011-09-12 16:45:37 +0000 (Mon, 12 Sep 2011) $	 
 */
package com.proyecto404.core.io {
	import com.proyecto404.core.BaseObject;
	import com.proyecto404.core.EventArgs;
	import com.proyecto404.core.IJob;
	
	import org.osflash.signals.ISignal;
	import org.osflash.signals.Signal;
	
	public class LoadDisplayObjectJob extends BaseObject implements IJob {
		private var _file:String;
		private var _loader:DisplayObjectLoader;
		
		public function LoadDisplayObjectJob(file:String) {
			_file = file;
			_loader = new DisplayObjectLoader();
		}
		
		public function execute(callback:Function):void {
			_loader.loaded.addOnce(function(e:EventArgs):void {
				callback.call(null, e);
			});
			
			_loader.load(_file);
		}
		
		public function get progress():ISignal {
			return _loader.progress;
		}

		public function get error():ISignal {
			return _loader.loadError;
		}

	}
}